<template>
	<!-- 用户主页 -->
	<view class="container">
		<view class="user-details">
			<view class="avatar-container">
				<image class="avatar" :src="data.avatar" mode="aspectFill" @tap="gotoAvatar()"></image>
			</view>
			<view class="user-info"  @tap="gotoIndex()">
				<view class="username">{{data.username}}</view>
				<view class="bintro">{{data.intro}}</view>
			</view>
			<view class="followb">
				<uni-fav :checked="checkL" :content-text="contentText" :star="false" bg-color="darkgoldenrod" fg-color="white" bg-color-checked="white" fg-color-checked="darkgoldenrod" @click="favClick(checkL)" />
			</view>
		</view>
		<view class="counter">
			<view class="fans" @tap="gotoFans">
				<text>{{fansnum}}</text>
				<text>粉丝数</text>
			</view>
			<view class="fans" @tap="gotoFollow">
				<text>{{follownum}}</text>
				<text>关注数</text>
			</view>
		</view>
		<Myframe></Myframe>
		<view><button @click="layout">退出登录</button></view>
	</view>
</template>

<script>
	import {useUserInfoStore} from '/pages/stores/userInfo.js'
	import { useTokenStore } from '../stores/token'
	import http from '/pages/utils/request.js'
	const tokenStore = useTokenStore()
	const userStore = useUserInfoStore()
	export default {
		data() {
			return {
				fansnum:0,
				follownum:0,
				checkL:false,
				data:{},
				contentText: {
					contentDefault: '关注',
					contentFav: '已关注'
				},
			}
		},
		onLoad() {
			this.data=JSON.parse(window.localStorage.getItem("user"))
			console.log(this.data,"this data")
		},
		methods: {
			layout() {
				tokenStore.removeToken()
				localStorage.clear()
				uni.redirectTo({
					url:'/pages/views/login'
				})
			},
			favClick(index) {
							this.checkL = !this.checkL
							console.log(this.checkL);
							this.$forceUpdate()
			},
			gotoIndex(){
				uni.navigateTo({
					url:'/pages/views/Mydetail'
				})
			},
			gotoAvatar(){
				uni.navigateTo({
					url:'/pages/views/Myavatar'
				})
			},
			gotoFans(){
				uni.navigateTo({
					url:'/pages/views/Mfans'
				})
			},
			gotoFollow(){
				uni.navigateTo({
					url:'/pages/views/Myfollow'
				})
			}
		}
	}
</script>

<style scoped>
	.container{
		width: 100%;
		height: 100%;
		background-color: #ff9b37;
	}
	.user-details {
		display: flex;
		flex-direction: row;
		align-items: center;
		width: 750rpx;
		height: 250rpx;
		border-radius: 25rpx 25rpx 0 0;
		justify-content: space-around;
		margin: 10rpx 0;
	}

	.avatar-container {
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-bottom: 20rpx;
	}

	.avatar {
	  width: 100%;
	  height: 100%;
	}

	.user-info {
		width: 400rpx;
		height: 200rpx;
		flex-direction: column;
	}

	.username {
		color: white;
		width: 400rpx;
		height: 80rpx;
		font-size: 40rpx;
		font-weight: bold;
		margin: 10rpx 0;
	}

	.bintro {
		width: 400rpx;
		height: 100rpx;
		font-size: 20rpx;
		color: #666;
	}
	.counter{
		width: 750rpx;
		height: 120rpx;
		border-radius: 30rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		background-color: beige;
		margin: 20rpx 0;
	}
	.fans{
		width: 120rpx;
		height: 60rpx;
		color: darkgoldenrod;
		margin: 10rpx 0;
		text-align: center;
		display: flex;
		flex-direction: column;
	}
	
</style>

